package com.zsz.ba02;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;



    @Component("myStudent")

//@Value简单类型的属性赋值(顶替了set（）方法)用的反射机制


public class Student {
        @Value(value ="赵书正" )
    private String name;
        @Value(value = "20")
    private Integer age;

    public Student() {
        System.out.println("==Student的无参构造方法调用了。==");
    }

    public void setName(String name) {
        this.name = name;
    }

    @Value("25")
    public void setAge(Integer age) {
        System.out.println("setAge:"+age);
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
